package com.example.parkdemo.sign

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class SignViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val signSuccess by lazy { MutableLiveData<String>() }
    fun sign(body: RequestBody) {
        viewModelScope.launch {
            executeNetWork(
                { apiService.sign(body) },
                signSuccess::postValue
            )
        }
    }

    val endSignSuccess by lazy { MutableLiveData<String>() }
    fun endSign(body: RequestBody) {
        viewModelScope.launch {
            executeNetWork(
                { apiService.endSign(body) },
                endSignSuccess::postValue
            )
        }
    }
}